Report post
Why does array_push() raise a warning if the first argument is not an array?
Note: If you use array_push () to add one element to the array, it's better to use $array = because in that way there is no overhead of calling a function. Note: array_push () will raise a warning if the first argument is not an array. This differed from the $var behaviour where a new array was created, prior to PHP 7.1.0. The input array.How to append an array to itself without overriding a previous element?
The most useful answer when looking for a simple way to append an array to itself without overriding any previous elements. array_push accepts a single argument since php 7.3, which prevents errors with empty arrays. A little note: This doesn't work with associative arrays. (Fatal Error: Cannot unpack array with string keys)What's the difference between array_push and empty bracket notation?
There's another difference between array_push and the recommended empty bracket notation. Empy bracket doesn't check if a variable is an array first as array_push does. If array_push finds that a variable isn't an array it prints a Warning message if E_ALL error reporting is on.How do I add more elements to an array?
For something like continuous addition to the array. You can keep track of the index and go on adding elements till you reach end and have the function that does the addition return you the next index, which in turn will tell you how many more elements can fit in the array.